package com.wf.day_0610.test1;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author mpk
 * @since 2024/6/10 18:13:07
 */
 class ReflectDemo {
    public static void main(String[] args) {

        ReentrantLock lock = new ReentrantLock();


        byte[] bytes = new byte[0];
        Thread thread = new Thread(
                () -> {
                    synchronized (bytes) {
                        try {
                            System.out.println("hello world11111111111");
                            Thread.sleep(2000);
                            //bytes.wait(2000);

                            lock.tryLock(2000, TimeUnit.MILLISECONDS);

                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        System.out.println("hello world11111111111");
                    }
                }
        );
    thread.start();
        Thread thread1 = new Thread(
                () -> {
                    synchronized (bytes) {
                        try {
                            System.out.println("hello world2222222");
                         //   bytes.wait(1000);

                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        System.out.println("hello world2222222");
                    }
                }
        );
        thread1.start();

    }

}
